/*    */ package com.zimbra.cs.mailclient.util;
/*    */ 
/*    */ import java.io.IOException;
/*    */ import java.io.OutputStream;
/*    */ import java.nio.ByteBuffer;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public final class Ascii
/*    */ {
/*    */   public static String pp(byte b)
/*    */   {
/* 34 */     switch (b) {
/* 35 */     case 0:  return "\\0";
/* 36 */     case 8:  return "\\b";
/* 37 */     case 13:  return "\\r";
/* 38 */     case 10:  return "\\n";
/* 39 */     case 9:  return "\\t";
/* 40 */     case 12:  return "\\f";
/*    */     }
/* 42 */     return "\\0x" + toHexChar(b >> 4 & 0xF) + toHexChar(b & 0xF);
/*    */   }
/*    */   
/*    */ 
/*    */   public static char toHexChar(int digit)
/*    */   {
/* 48 */     switch (digit) {
/*    */     case 0: case 1: case 2: case 3: case 4: 
/*    */     case 5: case 6: case 7: case 8: case 9: 
/* 51 */       return (char)(48 + digit);
/*    */     case 10: case 11: case 12: case 13: case 14: case 15: 
/* 53 */       return (char)(97 + digit - 10);
/*    */     }
/* 55 */     throw new IllegalArgumentException(String.valueOf(digit));
/*    */   }
/*    */   
/*    */   public static String toString(byte[] b)
/*    */   {
/* 60 */     char[] c = new char[b.length];
/* 61 */     for (int i = 0; i < b.length; i++) {
/* 62 */       c[i] = ((char)(b[i] & 0xFF));
/*    */     }
/* 64 */     return new String(c);
/*    */   }
/*    */   
/*    */   public static String toString(ByteBuffer bb) {
/* 68 */     bb = bb.slice();
/* 69 */     char[] c = new char[bb.remaining()];
/* 70 */     for (int i = 0; bb.hasRemaining(); i++) {
/* 71 */       c[i] = ((char)(bb.get() & 0xFF));
/*    */     }
/* 73 */     return new String(c);
/*    */   }
/*    */   
/*    */   public static byte[] getBytes(String s) {
/* 77 */     byte[] b = new byte[s.length()];
/* 78 */     for (int i = 0; i < s.length(); i++) {
/* 79 */       b[i] = ((byte)s.charAt(i));
/*    */     }
/* 81 */     return b;
/*    */   }
/*    */   
/*    */   public static void write(OutputStream os, String s) throws IOException {
/* 85 */     for (int i = 0; i < s.length(); i++) {
/* 86 */       os.write(s.charAt(i));
/*    */     }
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/mailclient/util/Ascii.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */